package com.atguigu.spring6;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestUser {
    @Test
    public void test(){
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        //根据id值获取bean
        User user1 = (User) context.getBean("user");
        System.out.println("根据id值获取内容为:"+user1);
        //根据属性名获取bean
        User user2 = context.getBean(User.class);
        System.out.println("根据属性名获取内容为:"+user2);
        //根据属性名和id值获取bean
        User user3 = context.getBean("user",User.class);
        System.out.println("根据id值和属性名获取内容为:"+user3);
    }

}
